package com.itcheetah.springevent.publisher;

import lombok.AllArgsConstructor;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @className: EventTest
 * @description: 孙悟空敲地测试类
 * @author: cheetah
 * @date: 2021/11/29 17:12
 * @Version: 1.0
 */
@RestController
@AllArgsConstructor
@RequestMapping("/event")
public class EventController {

    private final ApplicationEventPublisher applicationEventPublisher;

    @PostMapping
    public void testEvent(@RequestParam boolean knockGround) {
        MonkeyKing monkeyKing = new MonkeyKing();
        monkeyKing.setKnockGround(knockGround);
        MonkeyKingEvent monkeyKingEvent = new MonkeyKingEvent(monkeyKing);
        applicationEventPublisher.publishEvent(monkeyKingEvent);
    }
}
